package com.hhit.zhgd.controller

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.hhit.zhgd.domain.entity.ZhgdMachineryAlarm
import com.hhit.zhgd.domain.response.BaseResp
import com.hhit.zhgd.service.ZhgdMachineryAlarmService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
class ZhgdMachineryAlarmController {
    @Autowired
    private val zhgdMachineryAlarmService: ZhgdMachineryAlarmService? = null

    @GetMapping("pageMachineryAlarms")
    fun pageMachineryAlarms(
        @RequestParam(name = "page", defaultValue = "1") page: Int,
        @RequestParam(name = "size", defaultValue = "15") size: Int
    ): BaseResp<Any?>? {
        val pageInfo = Page<ZhgdMachineryAlarm>(page.toLong(), size.toLong())
        return BaseResp.success(
            zhgdMachineryAlarmService!!.page(
                pageInfo,
                QueryWrapper<ZhgdMachineryAlarm>().orderByDesc("create_time")
            )
        )
    }
}